import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
//vuex本地持久化存储
import createPersistedState from "vuex-persistedstate";
const store = new Vuex.Store({
	plugins: [
		createPersistedState({
			storage: {
				getItem: (key) => uni.getStorageSync(key),
				setItem: (key, value) => uni.setStorageSync(key, value),
				removeItem: (key) => uni.removeStorageSync(key),
			},
		}),
	],
	state: {
		token: uni.getStorageSync('token') || undefined
	},
	mutations: {
		setToken(state, token) {
			state.token = token
		}
	},
	actions: {

	}
})
export default store
